home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 3.1 KB | 154 lines | [TEXT/ToyS] |
- -- Preferences
- property kasPrefName : "Drop Shred 1.0"
-
- -- Globals
- global gasInfoWind -- Info window
- global gasInfoPos -- Position of info window
- global gasFoldersToDo -- The folders left to process
- global gasTrashed -- Number gone!
- global gasChecked -- Number checked!
-
-
- on run
- -- Set our icon to trash
- set the icon of (path to me) ¬
- to (the icon for (path to trash))
- tell application "Finder" to update (path to me)
- end run
-
- on open fsObjs
- -- Load prefs, show window
- pfLoad()
-
- set gasTrashed to 0
- set gasChecked to 0
-
- set gasInfoWind to display info titled kasPrefName ¬
- located at gasInfoPos ¬
- message "Scanning…"
-
- -- Do files
- set gasFoldersToDo to {}
-
- repeat with fsObj in fsObjs
- set myInfo to (basic info for fsObj)
-
- if (system type of myInfo is "fold") then
- set gasFoldersToDo to gasFoldersToDo & {fsObj}
- else
- DoOne(fsObj)
- end if
- end repeat
-
- -- Do folders
- repeat while gasFoldersToDo is not {}
- -- Pop one off the end
- set n to the number of items of gasFoldersToDo
- set fsObj to item n of gasFoldersToDo
-
- if (n > 1) then
- set gasFoldersToDo to items 1 through (n - 1) of gasFoldersToDo
- else
- set gasFoldersToDo to {}
- end if
-
- display info gasInfoWind ¬
- message ("Folders to go: " & n) ¬
- at line 6 ¬
- using color (15 * 32)
-
- -- Process it
- GoDeep(fsObj)
- end repeat
-
- display info gasInfoWind message "DONE!"
-
- set gasInfoPos to screen location of ¬
- (display info gasInfoWind with disposal)
-
- pfSave() -- Save window location
- end open
-
-
- on DoOne(fsObj)
- set aFileInfo to (alias info from fsObj)
-
- display info gasInfoWind ¬
- message "File: " & (original name of aFileInfo) ¬
- at line 2
-
- set gasChecked to gasChecked + 1
- display info gasInfoWind ¬
- message ("Checked: " & gasChecked) ¬
- at line 7 ¬
- using color 15
-
- try
- collate fsObj with the deleter
- set gasTrashed to gasTrashed + 1
- on error
- beep
- end try
-
- display info gasInfoWind ¬
- message ("Trashed: " & gasTrashed) ¬
- at line 8 ¬
- using color (15 * 1024)
- end DoOne
-
-
- on GoDeep(foldObj)
- display info gasInfoWind ¬
- message "Path: " & (foldObj as string)
-
- set daddy to foldObj as string
-
- -- Do aliases
- display info gasInfoWind ¬
- message "Scanning aliases" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are an alias
-
- repeat with myItem in myItems
- DoOne((daddy & myItem) as alias)
- end repeat
-
- -- Do files
- display info gasInfoWind ¬
- message "Scanning aliases" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a file
-
- repeat with myItem in myItems
- DoOne((daddy & myItem) as alias)
- end repeat
-
- -- Do folders
- display info gasInfoWind ¬
- message "Scanning subfolders" at line 5
-
- set myItems to the entries in foldObj ¬
- whose kinds are a folder
-
- repeat with myItem in myItems
- set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
- end repeat
- end GoDeep
-
-
- on pfLoad()
- try
- set ourPrefs to (load preference named kasPrefName)
- set gasInfoPos to item 1 of ourPrefs
- on error
- set gasInfoPos to {0, 0}
- end try
- end pfLoad
-
-
- on pfSave()
- save preference {gasInfoPos} named kasPrefName
- end pfSave
-